//
//  HNSH_NoticeCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/2/28.
//

#import "HNSH_NoticeCell.h"

@interface HNSH_NoticeCell ()
/**  */
@property (nonatomic, strong)UILabel * timeLabel;
/**  */
@property (nonatomic, strong)UIView * bgView;
/**  */
@property (nonatomic, strong)UILabel * titleLabel;
/**  */
@property (nonatomic, strong)UILabel * conLabel;
@end

@implementation HNSH_NoticeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor appBGColor];
        self.backgroundColor = [UIColor appBGColor];
        [self addAllViews];
        [self addAllLayout];
    }
    return self;
}


//MARK: Myself Methods
- (void)addAllViews{
    self.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.titleLabel];
    [self.bgView addSubview:self.conLabel];
}

- (void)addAllLayout{
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.mas_equalTo(24);
        make.height.mas_equalTo(17);
    }];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.mas_equalTo(self.timeLabel.mas_bottom).offset(12);
        make.bottom.mas_equalTo(0);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.mas_equalTo(16);
    }];
    [self.conLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.titleLabel);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(12);
        make.bottom.mas_equalTo(-16);
    }];
}

//MARK: Setter Methods
- (void)setModel:(HNSH_NoticeModel *)model{
    self.timeLabel.text = model.publish_time;
    self.titleLabel.text = model.title;
    self.conLabel.text = model.content;
}

//MARK: Getter Methods
- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [UILabel new];
        _timeLabel.font = [UIFont systemFontOfSize:12];
        _timeLabel.textColor = [UIColor colorWithHexString:@"#999999"];
        _timeLabel.textAlignment = NSTextAlignmentCenter;
        _timeLabel.text = @"2021-09-05 11:54:24";
    }
    return _timeLabel;
}

- (UIView *)bgView{
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.cornerRadius = 8;
        _bgView.layer.masksToBounds = YES;
    }
    return _bgView;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.font = [UIFont boldSystemFontOfSize:16];
        _titleLabel.textColor = [UIColor appBlack333LabelColor];
        _titleLabel.text = @"官方公告";
    }
    return _titleLabel;
}

- (UILabel *)conLabel{
    if (!_conLabel) {
        _conLabel = [UILabel new];
        _conLabel.font = [UIFont systemFontOfSize:14];
        _conLabel.textColor = [UIColor colorWithHexString:@"#999999"];
        _conLabel.numberOfLines = 0;
        _conLabel.text = @"不要再纠缠于“长期”和“短期”，很多时候长期已经成为了现在不做事情的借口";
    }
    return _conLabel;
}

@end
